#pragma once

#include <QWidget>
#include <QTimer>
#include <QPushButton>
#include <QPaintEvent>
#include <QPropertyAnimation>
#include <QButtonGroup>
#include <QLayout>
#include <QPainter>
#include "ui_CCarouseImageWidget.h"
#include "CStoryCellData.h"

QT_BEGIN_NAMESPACE
namespace Ui { class CCarouseImageWidgetClass; };
QT_END_NAMESPACE

class CCarouseImageWidget : public QWidget
{
	Q_OBJECT

public:
	CCarouseImageWidget(QWidget *parent = nullptr);
	~CCarouseImageWidget();
	void SetUi(const QVector<CStoryCellData*>& listStoryCellData);
	void StartPlay();
private:
	Ui::CCarouseImageWidgetClass *ui;
	QVector<CStoryCellData*> m_listStoryCellData;
	QVector<QString> m_listImage;
	QVector<QPushButton*> m_listButton;

	int m_nCurrentIndex;
	QPixmap m_pmCurrentPixmap;
	QPixmap m_pmNextPixmap;

	QTimer* m_pTimer;
	QPropertyAnimation* m_pAnimation;

	virtual void paintEvent(QPaintEvent* pQPaintEvent) override;
	virtual void mousePressEvent(QMouseEvent* pQMouseEvent) override;

private:
	void InitButton();

signals:
	void CarouseImageClick(CStoryCellData*);

private slots:
	void OnImageChangeTimeout();
	void OnImageSwitchButtonClick(int nButtonId);
};
